package de.koller.worlders.gameplay.gui;

import de.koller.oceanFramework.gl.util.IRenderableImage;
import de.koller.worlders.WSea;
import de.koller.worlders.WorldersRoot;
import de.koller.worlders.render.IGLRender;
import de.koller.worlders.render.util.TextureRep;
import org.lwjgl.opengl.GL11;

public class AchieveGetDisp extends WSea implements IGLRender {

	private IRenderableImage ach;
	private float rot = 0;
	private boolean show = false;
	private boolean ignorShow = false;
	
	@Override
	protected void init() {
		super.init();
		
		ach = new TextureRep( TextureRep.TextureValue.Tiles, 128, 32, 32, 32 ).generate( wroot.getBuffers() );
	}

	@Override
	public void renderGL( int elapsedTime ) {
		if( !show )
			return;
		
		GL11.glPushMatrix();
		
		GL11.glTranslatef( WorldersRoot.D_WIDTH/2, WorldersRoot.D_HEIGHT/2, 0 );
		GL11.glRotatef( rot, 0, 0, 1 );
		GL11.glTranslatef( -WorldersRoot.D_WIDTH/2, -WorldersRoot.D_HEIGHT/2, 0 );
		
		ach.draw2D( WorldersRoot.D_WIDTH/2-100, WorldersRoot.D_HEIGHT/2-100, 200, 200, 60 );
		
		GL11.glPopMatrix();
	}

	@Override
	protected void update( int elapsedTime ) {
		super.update( elapsedTime );
		
		rot += 0.1 * elapsedTime;
		if( rot > 360 )
			show = false;
	}

	public void showAch() {
		if( ignorShow )
			return;
		
		show = true;
		rot = 0;
	}

	public void setIgnorShow( boolean ignorShow ) {
		this.ignorShow = ignorShow;
	}

}
